import pymysql

# 1、创建数据库链接
with pymysql.connect(host="master", port=3306, database="bigdata31", user="root", password="123456") as con:
    # 2、获取游标,用于执行sql
    cursor = con.cursor()

    # 3、执行sql插入数据
    cursor.execute(
        "insert into students(id,name,age,gender,clazz) values(%s,%s,%s,%s,%s)",
        ["1500100001", "施笑槐", 22, "女", "文科六班"])

    # 4、提交
    con.commit()
